import ezhou from "$ui/charts/geo/city/420700.json";
var data = [
  { name: "华容区", value: 110 },
  { name: "鄂城区", value: 110 },
  { name: "梁子湖区", value: 110 },
];

// function randomData() {
//   return Math.round(Math.random() * 500);
// }
var geoCoordMap = {
  华容区: [114.70284461975099, 30.533285143560821],
  鄂城区: [114.88583564758299, 30.394458582600354],
  梁子湖区: [114.68112945556641, 30.107080761488419],
};
var convertData = function(data) {
  var res = [];
  for (var i = 0; i < data.length; i++) {
    var geoCoord = geoCoordMap[data[i].name];
    if (geoCoord) {
      res.push({
        name: data[i].name,
        value: geoCoord.concat(Number(data[i].value)),
      });
    }
  }
  return res;
};
export default {
  title: {
    padding: 20,
    text: "省级当前治愈率分布图",
    subtext: "截止至2020年2月5日中午",
    x: "left",
    textStyle: {
      color: "#fff",
    },
    subtextStyle: {
      fontStyle: "italic",
    },
  },
  tooltip: {
    trigger: "item",
    showDelay: 0,
    transitionDuration: 0.2,
    formatter: function(params) {
      var value = (params.value[2] + "").split(".");
      return "治愈率" + "<br/>" + params.name + ":" + value + "%";
    },
  },
  legend: {
    show: false,
    orient: "vertical",
    left: "left",
    data: [""],
  },
  visualMap: {
    min: 0,
    max: 100,
    pieces: [
      {
        min: 99,
        max: 100,
      },
      {
        min: 80,
        max: 99,
      },
      {
        min: 60,
        max: 80,
      },
      {
        min: 40,
        max: 60,
      },
      {
        min: 20,
        max: 40,
      },
      {
        min: 0,
        max: 20,
      },
    ],
    inRange: {
      color: ["#780000", "#fb0300", "#e59306", "#d7e573", "#8abda7", "#2396cf"],
    },
    textStyle: {
      color: "#fff",
    },
  },
  //定义了一个坐标系
  geo: {
    map: "ezhou",
    label: {
      normal: {
        show: false,
      },
      emphasis: {
        show: false,
      },
    },
    itemStyle: {
      //未激活样式
      normal: {
        areaColor: "white",
        borderColor: "black",
      },
      //激活样式
      emphasis: {
        areaColor: "white",
      },
    },
  },
  selectedMode: "single",
  series: [
    {
      name: "治愈率",
      type: "scatter",
      symbolSize: 10, //控制点的大小
      // coordinateSystem: "geo",
      data: convertData(data), //加载数据

      label: {
        normal: {
          show: false,
        },
        emphasis: {
          show: false,
        },
      },
    },
    {
      name: "鄂州",
      type: "map",
      roam: true,
      map: ezhou,
      emphasis: {
        label: {
          show: true,
        },
      },
      // 文本位置修正
      textFixed: {
        Alaska: [20, -20],
      },
      data: [],
    },
  ],
};
